package net.siufung.boot.datasource.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import net.siufung.boot.datasource.rules.IDbDriver;
import net.siufung.boot.datasource.rules.IDbType;
import net.siufung.core.model.IEnum;

/**
 * @author 陈建峰
 * @since 2022/8/11 5:55 下午
 */
@AllArgsConstructor
public enum DbDrivers implements IDbDriver, IEnum<IDbType> {

    /**
     * MySql5数据库
     */
    MYSQL_5(DbTypes.MYSQL_5, "com.mysql.jdbc.Driver"),

    /**
     * MySql8数据库
     */
    MYSQL_8(DbTypes.MYSQL_8, "com.mysql.cj.jdbc.Driver");

    @Getter
    @Setter
    private IDbType value;

    @Getter
    @Setter
    private String desc;

    public static DbDrivers get(IDbType dbType) {
        return IEnum.get(DbDrivers.class,
                enums -> enums.getValue().equals(dbType));
    }

}
